package com.googlecode.perfectable.visuable.configuration;

import com.googlecode.perfectable.introspection.Bean;
import com.googlecode.perfectable.introspection.Classes;
import com.googlecode.perfectable.visuable.event.Event;
import com.googlecode.perfectable.visuable.event.EventListener;
import com.googlecode.perfectable.visuable.visual.Visual;
import com.googlecode.perfectable.visuable.visual.controller.Controller;

public class StandardConfigurator implements Configurator {

	@Override
	public <C extends Visual, T extends Controller<? super C>> T createController(Class<T> controllerClass,
			Class<C> visualClass) {
		return Classes.instantiate(controllerClass);
	}

	@Override
	public <E extends Event, T extends EventListener<? super E>> T createListener(Class<T> listenerClass,
			Class<E> eventClass) {
		return Classes.instantiate(listenerClass);
	}

	@Override
	public void injectVisual(Object target, String propertyName, Visual visual) {
		Bean.from(target).property(propertyName, Visual.class).set(visual);
	}

}
